﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    #region Nguyen Thanh Duy

    public static class CustomDAO
    {
        public static DataTable TableQuery(string sql)
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            return Dataprovider.laythongtinbang(sql, con);
        }
        public static Boolean FTableDirect(DataTable dt, string tenbang)
        {
            try
            {
                OleDbCommand cmt = new OleDbCommand();
                OleDbDataAdapter da = new OleDbDataAdapter();
                OleDbCommandBuilder cmb = new OleDbCommandBuilder();
                OleDbConnection con = Dataprovider.ketnoicsdl();
                cmt.Connection = con;
                cmt.CommandType = CommandType.TableDirect;
                cmt.CommandText = tenbang;
                da.SelectCommand = cmt;
                cmb.DataAdapter = da;
                da.Update(dt);
                dt.AcceptChanges();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }

    #endregion
}
